package cn.smile.config.admin;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import cn.smile.constant.RuntimeConstant;
import cn.smile.interceptor.admin.AuthorityInterceptor;
import cn.smile.interceptor.admin.AdminLoginInterceptor;

import javax.annotation.Resource;

/**
 * 用来配置拦截器的配置类
 */
@Configuration
public class AdminWebConfig implements WebMvcConfigurer {

    @Resource
    private AdminLoginInterceptor loginInterceptor;

    @Resource
    private AuthorityInterceptor authorityInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns(RuntimeConstant.loginExcludePathPatterns);
        registry.addInterceptor(authorityInterceptor).addPathPatterns("/**").excludePathPatterns(RuntimeConstant.authorityExcludePathPatterns);
    }

}
